package com.maomao.beans;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

public class factory {

	public static User create(HttpServletRequest request)
	{
		int userType = Integer.parseInt(request.getParameter("userType"));
		String userName = request.getParameter("userName");
		String passwd = request.getParameter("userPassword");
		
		
		
		if(userType==1)
		{
			User stu = new student();
			stu.setName(userName);
			stu.setPasswd(passwd);
			stu.setUserType(userType);
			System.out.println("I am a student");
			return stu;
			
		}
		else if(userType==2)
		{
			User teacher = new teacher();
			teacher.setName(userName);
			teacher.setPasswd(passwd);
			teacher.setUserType(userType);
			return teacher;
		}
		else 
		{
			User ta = new ta();
			ta.setName(userName);
			ta.setPasswd(passwd);
			ta.setUserType(userType);
			return ta;
		}
		
	}
}
